<?php 
$this->headLink(array('href' => '/cms/styles/style.css', 'rel' => "stylesheet", 'type' => "text/css"));
$this->headStyle(<<<EOD
#List {
	overflow: auto;
	height: 350px;
	margin-right: -6px;
}
EOD
);


$this->headScript(Zend_View_Helper_HeadScript::SCRIPT,<<<EOD
function AddRow() {
	var rowEl = document.createElement('TR');
	
	var cellEl1 = document.createElement('TD');
	var minusBtn = document.createElement('BUTTON');
	minusBtn.type = 'button';
	minusBtn.onclick = function () {
			removeRow(rowEl);
		}
	var minusIm = document.createElement('IMG');
	minusIm.src = '/cms/images/minus.png';
	minusIm.width = '16';
	minusIm.height = '16';
	minusBtn.appendChild(minusIm);
	cellEl1.appendChild(minusBtn);
	rowEl.appendChild(cellEl1);
	
	var cellEl2 = document.createElement('TD');
	var paramKeyFld = document.createElement('INPUT');
	paramKeyFld.type = 'text';
	paramKeyFld.name = 'param_key[]';
	paramKeyFld.className = 'modalInput';
	cellEl2.appendChild(paramKeyFld);
	rowEl.appendChild(cellEl2);
	
	var cellEl3 = document.createElement('TD');
	var paramValueFld = document.createElement('INPUT');
	paramValueFld.type = 'text';
	paramValueFld.name = 'param_value[]';
	paramValueFld.className = 'modalInput';
	cellEl3.appendChild(paramValueFld);
	rowEl.appendChild(cellEl3);
	
	var ctrlEl = document.getElementById('controllRow');
	ctrlEl.parentNode.insertBefore(rowEl,ctrlEl);
}

function removeRow(row) {
	if (typeof row != 'object') {
		row = document.getElementById(row);
	}
	var rowParent = row.parentNode;
	rowParent.removeChild(row);
}
EOD
);


$this->layout()->body_attr = 'class="modal"';
?>
<form action="" method="post">
  <div id="List">
  <table border="0" cellpadding="2" cellspacing="0" class="form" id="paramTable">
      <?php for ($p=0;$p<count($this->param_list);$p++) {?>
      <tr id="row<?= $p ?>">
        <td><button type="button" onclick="removeRow('row<?= $p ?>')"><img src="/cms/images/minus.png" width="16" height="16" /></button></td>
        <td><input name="param_key[]" type="text" class="modalInput" value="<?= $this->param_list[$p][0] ?>" /></td>
        <td><input name="param_value[]" type="text" class="modalInput" value="<?= $this->param_list[$p][1] ?>" /></td>
      </tr>
      <?php } ?>
      <tr id="controllRow">
        <td><button onclick="AddRow()" type="button"><img src="/cms/images/plus.png" width="16" height="16" /></button></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>  
  </div>
  <div style="padding-top:20px">
    <input type="submit" class="okButton" value="Сохранить" />
    <input type="button" class="okButton" value="Отмена" onclick="window.parent.setTimeout('Shadowbox.close()',10)" />
  </div>
</form>